# Maintainer: Antonio Rojas <arojas@archlinux.org>

pkgname=appstream-generator
pkgver=0.9.0
pkgrel=3
pkgdesc='A fast AppStream metadata generator'
arch=(loong64 x86_64)
url='https://github.com/ximion/appstream-generator'
license=(GPL3)
depends=(appstream libarchive librsvg optipng glibd lmdb)
makedepends=(ldc meson ninja mustache-d curl gir-to-d gobject-introspection docbook-xsl)
source=(
  https://github.com/ximion/appstream-generator/archive/v$pkgver/$pkgname-$pkgver.tar.gz
  "undeaD-1.1.8.tar.gz::https://github.com/dlang/undeaD/archive/refs/tags/v1.1.8.tar.gz"
  "undeaD-xml.patch"
)
sha256sums=('7964924feb09348444cb8159fd2c22415f5df61d451d9f769f18d5b606d2cf52'
            '36a59b4740b147f4345caa26908f40a97fc7cc67dac6983c226369c59f909e92'
            '3075e264251624b8d491d61a07a95ac70a21af8eeabcf5da9493619b3d1eadd2')

prepare() {
  # Patch in undead.xml as std.xml has been removed
  patch --directory="$pkgname-$pkgver" --forward --strip=1 --input "$srcdir"/undeaD-xml.patch
  cd "$srcdir"/$pkgname-$pkgver
  ln -s "$srcdir"/undeaD-1.1.8
}

build() {
  export LDFLAGS="$(echo -ne $LDFLAGS | sed -e 's/-flto=auto/-flto=full/')"
  arch-meson $pkgname-$pkgver build -D download-js=false
  meson compile -C build
}

package() {
  meson install -C build --destdir="$pkgdir"
}
